/*
 *  perlinnoiseScene.h
 *  opencvExample
 *
 *  Created by 真鍋 大度 on 11/03/01.
 *  Copyright 2011 Rhizomatiks. All rights reserved.
 *
 */

#pragma once
#include "ofMain.h"
#include "basePattern.h"

class perlinnoiseScene : public basePattern{
public:
	void setup(){
		allocate();
		for (int i = 0; i < h; i++){
			for (int j = 0; j < w; j++){
				float rate = 0.5;
				unsigned char tmpval = maxGray * ofNoise(j, i, ofGetFrameNum() * rate);
				currentColorPixels[(i*w+j)*3 + 0] = tmpval;
				currentColorPixels[(i*w+j)*3 + 1] = tmpval;
				currentColorPixels[(i*w+j)*3 + 2] = tmpval;		
			}
		}
	}
	void update(){
		for (int i = 0; i < h; i++){
			for (int j = 0; j < w; j++){
				float rate = 0.01;
				unsigned char tmpval = maxGray * ofNoise(j * 0.1, i * 0.1, ofGetFrameNum() * rate);
				currentColorPixels[(i*w+j)*3 + 0] = tmpval;
				currentColorPixels[(i*w+j)*3 + 1] = tmpval;
				currentColorPixels[(i*w+j)*3 + 2] = tmpval;		
			}
		}
		currentColorImage.setFromPixels(currentColorPixels, w, h);		
	}
};